<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.longtop.com/intelliweb" prefix="e"%>
<%@ page isELIgnored="false"%>
<html>
	<head>
		<title>考核方案-第四步任务管理-SJH</title>
	</head>
<e:View id="eView" designProperty="width: 1024; height: 768">
	<script type="text/javascript">SkinUtil.getSkin();</script>
	<script type="text/javascript">SkinUtil.getModuleSkin();</script>	
	<script type="text/javascript" src="<c:url value='/js/perform/perform.js'/>"></script>
	
	<div id="Invisual Controls" style="min-height: 40px;">
	
	<!--考核阶段 -->
		<e:Dataset id="Dataset_project_segment" pageSize="-1">
			<e:Field name="segmentId" label="分段ID" dataType="string"/>
			<e:Field name="projectId" label="考核方案ID" dataType="string"/>
			<e:Field name="cycleId" label="阶段周期ID" dataType="string"/>
			<e:Field name="segmentName" label="考核阶段名称" dataType="string"/>
			<e:Field name="status" label="状态" dataType="string"/>
			<e:Field name="startDate" label="开始日期" dataType="date"/>
			<e:Field name="endDate" label="结束日期" dataType="date"/>
			<e:Field name="scoreTime" label="计算时间"  dataType="date"/>
			<e:Field name="cycleName" label="阶段周期名称"  dataType="string"/>
		</e:Dataset>
	<!-- 考核方案-指标 -->
		<e:Dataset id="Dataset_project_index" pageSize="-1">
			<e:Field name="projectId" dataType="string"/>
			<e:Field name="indexId" dataType="string"/>
			<e:Field name="indexType" dataType="string"/>
			<e:Field name="indexUnit" dataType="string"/>
			<e:Field name="indexName" dataType="string" label="指标名称"/>
		</e:Dataset>		
	<!--任务对应员工-->
		<e:Dataset id="Dataset_task_user" pageSize="15"  loadDataCommand="Command_loadTaskUser">
			<e:Field name="taskId" dataType="string" label="任务ID" maxLength="32" visible="false"/>
			<e:Field name="taskName" dataType="string" label="任务名称" maxLength="200" visible="false"/>
			<e:Field name="segmentId" dataType="string" label="考核分段ID" maxLength="32" visible="false"/>
			<e:Field name="userId" dataType="string" label="员工ID" maxLength="32" readOnly="true" />
			<e:Field name="userName" label="员工名称" dataType="string" readOnly="true" />
			<e:Field name="orgName" label="员工所属机构" dataType="string" readOnly="true" />			
		</e:Dataset>
	<!--任务对应员工明细表-->
		<e:Dataset id="Dataset_task_user_mx" pageSize="-1" readOnly="true" datasetDefinition="DatasetDefinition_khuser.dsd" datasetRef="Dataset_Task_Mx">
			<e:Field name="id" dataType="string" label="ID" maxLength="32" visible="false"/>
			<e:Field name="segmentId" dataType="string" label="考核分段ID" maxLength="32" visible="false"/>
			<e:Field name="taskId" dataType="string" label="任务ID" maxLength="32" />
			<e:Field name="userId" dataType="string" label="员工ID" maxLength="32" />
			<e:Field name="indexId" dataType="string" label="指标ID" maxLength="32" />
			<e:Field name="taskValue" dataType="bigdecimal" label="任务值" maxLength="14" scale="2"/>
			<e:Field name="finishValue" dataType="bigdecimal" label="完成值" maxLength="14" scale="2"/>
		</e:Dataset>		
		
	<!-- 考核分段ID对应名称 -->
		<e:DataDropDown id="DataDropDown_segmentIdToName" dataset="Dataset_project_segment"
		      visibleFields="cycleName" codeField="segmentId" textField="cycleName" showColumnHeader="false" fixed="true"
		      onAfterSelect="DataDropDown_segmentIdToName_onAfterSelect()">
		</e:DataDropDown>
		
	<!-- 获取考核任务对应的员工明细 -->
		<e:Command id="Command_queryTaskUser" action="com.longtop.perform.khyg.web.TaskAction" method="queryTaskUser" showHintInfoOnSuccess="false" submitForm="true">
			<e:DatasetInfo name="info1" dataset="Dataset_task_user" submitType="none" alwayRefreshClient="true"/>
			<e:Parameter name="segmentId" dataType="string" value=""/>
		</e:Command>
		<e:Command id="Command_loadTaskUser" action="com.longtop.perform.khyg.web.TaskAction" method="queryTaskUser" showHintInfoOnSuccess="false" onBeforeExecute="Command_loadTaskUser_onBeforeExecute()">
			<e:Parameter name="segmentId" dataType="string" value=""/>
		</e:Command>
		
		<e:Command id="Command_submit" action="com.longtop.perform.khyg.web.TaskAction" method="submitTaskUser">
			<e:DatasetInfo name="info2" dataset="Dataset_project_index" submitType="all" />
			<e:DatasetInfo name="info1" dataset="Dataset_task_user"/>
		</e:Command>		

<body style="overflow: auto">
<e:Page id="ePage" action="com.longtop.perform.khyg.web.TaskAction" style="min-height: 80px; width: 100%; height: 100%;"  onAfterLoadPage="ePage_onAfterLoadPage()" onBeforeLoadPage="ePage_onBeforeLoadPage()">
	<table width="100%" height="100%" border="0" align="center" cellpadding="2" cellspacing="2">
		 <tr>
			<td align="left" valign="top">
					<table width="100%">
						<tr>
							<td valign="top" align="left">	
								<e:GroupBox id="GroupBox_project" style="width: 100%; " caption="考核方案">
									<table style="text-align: left; width: 100%;" border="0" cellpadding="2" cellspacing="2">
										<tr>
											<td align="right" nowrap="nowrap">&nbsp;&nbsp;</td>
											<td align="right" nowrap="nowrap"><e:Label id="Label_projectName" caption="考核方案"/></td>
											<td align="left"> 
												<e:Text id="Text_projectName" style="width:250px" readOnly="true" />
	                						</td>									
											<td align="right" nowrap="nowrap"><e:Label id="Label_segmentName" caption="选择阶段"/></td>
											<td align="left" width="99%">
												<e:Text id="Text_segmentName" dropDown="DataDropDown_segmentIdToName" style="width:250px"/>
											</td>
										</tr>
									</table>
								</e:GroupBox>
							</td>
						</tr>
						<tr>
							<td>
								<table style="text-align: left; width: 100%;" border="0" cellpadding="0" cellspacing="0">
									<tr>
										<td height="27px" width="1%">
											<e:RecordNavigator id="RecordNavigator_segmentUser" dataset="Dataset_task_user" showNavigatorButton="false">
												<e:RecordButton id="RecordButton_choose" label="查询考核对象" onClick="RecordButton_choose_onClick()"  icon="/images/query.gif"></e:RecordButton>
		              							<e:RecordButton id="RecordButton_save" label="保存任务" command="Command_submit"  icon="/images/submit.gif"></e:RecordButton>
											</e:RecordNavigator>
										</td>
										<td align="left" width="99%"><e:PageNavigator id="PageNavigator" dataset="Dataset_task_user" showRecordNum="true" showPageSize="false"></e:PageNavigator></td>
									</tr>
								</table>
							</td>
						</tr>
						<tr>
							<td>
								<e:Grid id="Grid_segmentUser" style="width: 100%; height: 100%;" showIndex="true" dataset="Dataset_task_user" >
								</e:Grid>
								<e:Text id="Text_userIdListStr" visible="false"></e:Text>
							</td>
						</tr>	
					<table>
			</td>
		</tr>
	</table>
</e:Page>
</body>
<script language="Javascript">
	var projectId = '${param.projectId}';
	//init:
	function ePage_onBeforeLoadPage(){

	}
	function ePage_onAfterLoadPage(){
	 $J("Text_projectName").setValue(parent.$J("Text_projectName").getValue());//显示方案名称
		//考核方案无分段设置：
		if(isEmpty(Dataset_project_segment.getValue("cycleId"))){
			$J("Text_segmentName").setReadOnly(true);
			DataDropDown_segmentIdToName.onAfterSelect();
		}
	}
	//获取考核任务对应的员工明细
	function DataDropDown_segmentIdToName_onAfterSelect(){
 		var segmentId = Dataset_project_segment.getValue("segmentId");
		Command_queryTaskUser.parameters.setValue("segmentId",segmentId);
		Command_queryTaskUser.execute();
		if($J("Grid_segmentUser").isEmpty()){
			MsgBox.showWarnMsg("请到第3步考核对象管理，为该考核周期关联对象。");
		}
	}
	function Command_loadTaskUser_onBeforeExecute(){
		var segmentId = Dataset_project_segment.getValue("segmentId");
		Command_loadTaskUser.parameters.setValue("segmentId",segmentId);
	}	
	
	//选择考核对象
	function RecordButton_choose_onClick(){
		if(!$J("Text_segmentName").isReadOnly() && isEmpty($J("Text_segmentName").getValue())){
			MsgBox.showWarnMsg("请先选择考核阶段。");
			return;
		}
		var segmentId = Dataset_project_segment.getValue('segmentId');		
		var arrayMap = selectTaskUsersFromWindow(segmentId);//选择考核周期对应员工弹出框
		if(arrayMap == ''){
			return;
		}
		
		//组装用户listStr
		$J("Text_userIdListStr").setValue("");
		var userIdStr ="";
		for (var i =0 ; i<arrayMap.length ; i++){
			var userId = arrayMap[i].get("userId");
			userIdStr = userIdStr + "'"+userId+"',";
		}		
		$J("Text_userIdListStr").setValue(userIdStr);
		//alert($J("Text_userIdListStr").getValue());
		
 		var segmentId = Dataset_project_segment.getValue("segmentId");
		Command_queryTaskUser.parameters.setValue("segmentId",segmentId);
		Command_queryTaskUser.execute();		
		
	}
</script>
</e:View>
</html>